<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<title></title>
		<link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/css/layui.css}" />
		<link rel="stylesheet" th:href="@{/plugin/font-awesome/css/font-awesome.min.css}" media="all" />
		<link rel="stylesheet" th:href="@{/src/lvdong/origin/css/app.css}" media="all" />
		<link rel="stylesheet" th:href="@{/src/lvdong/origin/css/themes/default.css}" media="all" id="skin" kit-skin />
		<script th:src="@{/plugin/layui/layui.js}" type="text/javascript" charset="utf-8"></script>
  		<script th:src="@{/plugin/jquery/jquery-3.4.1.js}" charset="utf-8"></script>
</head>
<body>
	<form class="layui-form" action="" lay-filter="test">
		<div class="layui-form-item">
			<label class="layui-form-label">菜单</label>
			<div class="layui-input-block">
				<input type="text" id="add-menu" name="menuname" required
					lay-verify="required" placeholder="英文" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">描述</label>
			<div class="layui-input-block">
				<input type="text" id="add-description" name="description" required
					lay-verify="required" placeholder="做什么的" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="formDemo">添加菜单</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>

	<script>
		//Demo
		layui.use('form', function() {
			var form = layui.form;
			//监听提交
			form.on('submit(formDemo)', function(data) {
				$.ajax({
					url : "/menuMg/insertMenu",
					type : "POST",
					async : false,
					cache : false,
					data : {
						menu_name : $("#add-menu").val(),
						description : $("#add-description").val(),
					},
					dataType : 'json',
					success : function(data) {
						if (data != null) {
							layer.msg(data.msg);
						} else {
							layer.msg("服务器处理错误！");
						}
					},
					error : function() {
						console.log("ajax error");
					}
				});
			});
		});
	</script>
</body>
</html>
